<?php
require('conn.php');
require('functions.php');
require('session.php');
$id=guolv($_GET['id']);
$type=guolv($_GET['type']);
//print_r($userdata);

?>

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width,initial-scale=1.0, user-scalable=no, minimum-scale=1.0, maximum-scale=1.0" />
<?php if($type==0):?>
<title>新手学堂</title>
<?php else:?>
<title>消息中心</title>
<?php endif; ?>
<link href="<?php echo $site?>/static/all.css" type="text/css" rel="stylesheet" media="all">
<style>
body{
	overflow-x:hidden; 
}
td{font-size:1.3em;}
.bg{background: white}
.red{background-color: #f0585c;color: white;}
.green{background-color: #58f09b;color: white;}
.blue{background-color: #f0585c;color: white;}
.darkblue{color: white;padding-left: 1em;}
.num-img{     display: inline-block;
    width: 25px;
    color: white;
    background: #ec3a3a;
    text-align: center;
    border-radius: 50%;
    height: 25px;
    line-height: 25px;
    /*box-shadow: 0px 0px 5px white,0px 0px 6px #f0585c;*/
    /*-webkit-box-shadow: 0px 0px 5px white,0px 0px 6px #f0585c;*/
    float:left;
    margin-top: 8px;
}
.num-div{
    margin-top: 0.5em;
	height: 100%;
	width: 100%;
	
}
.hide{
	display: none;
}
.head{
	height: 40px;
	line-height:40px;
}
.body{
	 margin-left: -1em;
	 /*text-indent: 2em;*/
	 color: grey;
	 padding: 0px 1em;
}
.toTop{
	position: fixed;
	bottom: 15%;
	right: 12.5%;
	width: 25px;
	height: 25px;
	border-radius: 50%;
	background: url('static/images/back.png') no-repeat center center ;
	background-size: contain;
	transform: rotate(90deg);
	-webkit-transform: rotate(90deg);
	z-index: 10;
	/*box-shadow: 0px 0px 5px white,0px 0px 10px gold;*/
	/*background-color: #ec3a3a;*/
}
</style>
</head>

<body class="mhome bg">
<?php
if(is_numeric($id)==false){
?>
<table width="100%" border="0" cellspacing="3" cellpadding="0">
<?php
	if ($type==0) {
	$rows=$mysql->query("select * from `newsdata` where `type`={$type}  order by `id` limit 0,10");
	foreach($rows as $key =>$row){
	$index=$key+1;
	// var_dump($row);
print <<<tr
		<tr class="head">
		<td class="darkblue item"  style="background:none">
			<div class="head">
				<div class="num-div">
					<div class="num-img">{$index}</div>
					<a style="float:left;width:79%;color:rgb(56,56,56);font-size: 1.1em;margin-left: 5%;margin-right: 5%;border-bottom: 1px solid rgb(239,240,243);" target="_blank">
						<span>{$row['title']}</span>
					</a>
				</div>
			</div>
			<div class="body hide">
				{$row['content']}
			</div>
			
		</td>
	  </tr>
tr;
	}
		
}else if($type==1){
		$rows=$mysql->query("select * from `newsdata` where `type`={$type}  order by `id` limit 0,20");
	foreach($rows as $key=>$row){
		// var_dump($row);
		$index=$key+1;
print <<<tr
		<tr class="head">
		<td class="darkblue item"  style="background:none">
			<div class="head">
				<div class="num-div">
					<div class="num-img">{$index}</div>
					<a style="float:left;width:79%;color:rgb(56,56,56);font-size: 1.1em;margin-left: 5%;margin-right: 5%;border-bottom: 1px solid rgb(239,240,243);" target="_blank">
						<span>{$row['title']}</span>
					</a>
				</div>
			</div>
			<div class="body hide">
				{$row['content']}
			</div>
			
		</td>
	  </tr>
tr;
}
}
?>
</table>
<div style="width:100%;height:10%;"></div>
<?php } ?>
<div class="toTop" id="ro_top" style="display: none;"></div>
<?php
@session_start();
if(isset($_SESSION)){
	$_uid=$_SESSION['userdata']['id'];
}else{
	$_uid=guolv($_GET['uid']);
}
?>
<div class="positionFooter">
	<ul style="height:100%;">
		<?php if($type==0):?>
		<li><a class="a4" href="<?php echo $site?>/ucenter.php"></a></li>   
		<li><a class="a2" href="<?php echo $site?>/list.php?uid=<?php echo $_uid?>"></a></li>
		<li><a  class="a3" href="<?php echo $site?>/news.php?type=1"></a></li>
		<?php else:?>
		<li><a class="a1" href="<?php echo $site?>/ucenter.php"></a></li>   
		<li><a class="a2" href="<?php echo $site?>/list.php?uid=<?php echo $_uid?>"></a></li>
		<li><a  class="a6" href="<?php echo $site?>/news.php?type=1"></a></li>
		<?php endif; ?>
	</ul>
</div>
<?php
$mysql->__destruct();
$mysql->close();
?>
<script type="text/javascript" src="static/jquery-2.2.0.min.js"></script><script type="text/javascript" src="static/jquery.touch.js"></script>
<script type="text/javascript">
$(document).ready(function(){
	$('#ro_top').hide();
	$(window).scroll(function () {
		if ($(window).scrollTop() > 200) {
			$('#ro_top').fadeIn(400);//当滑动栏向下滑动时，按钮渐现的时间
		} else {
			$('#ro_top').fadeOut(0);//当页面回到顶部第一屏时，按钮渐隐的时间
		}
	});
	$('#ro_top').tap(function () {
        $('.body').fadeOut(0);
		$('html,body').animate({
			scrollTop : '0px'
		}, 300);//返回顶部所用的时间 返回顶部也可调用goto()函数
	});
});

$('.item .head').tap(function () {
	// console.log($(this).parent());
    if ($(this).hasClass('active')) {
        $(this).removeClass('active');
        $(this).parent().find('.body').fadeOut(0);
    } else {
        $(this).addClass('active');
        $(this).parent().find('.body').fadeIn(300);
    }
});
</script>
</body>
</html>
